<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: DNS</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__dns.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">DNS<div class="ingroups"><a class="el" href="group__api.html">APIs</a> &raquo; <a class="el" href="group__callbackstyle__api.html">&quot;raw&quot; APIs</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaf66c5d8273f83cdc2cdd8911fb68d584"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dns.html#gaf66c5d8273f83cdc2cdd8911fb68d584">dns_setserver</a> (u8_t numdns, const <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *dnsserver)</td></tr>
<tr class="separator:gaf66c5d8273f83cdc2cdd8911fb68d584"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad02111a6b26b93f1c3580d5f41a59af3"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dns.html#gad02111a6b26b93f1c3580d5f41a59af3">dns_getserver</a> (u8_t numdns)</td></tr>
<tr class="separator:gad02111a6b26b93f1c3580d5f41a59af3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1e040ec38166dc9bfcc3473aab0c799f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dns.html#ga1e040ec38166dc9bfcc3473aab0c799f">dns_gethostbyname</a> (const char *hostname, <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *addr, <a class="el" href="dns_8h.html#ab5a9dec5b22802f91876c53e99f427ae">dns_found_callback</a> found, void *callback_arg)</td></tr>
<tr class="separator:ga1e040ec38166dc9bfcc3473aab0c799f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae84449f60dca6b863142daca8e03ce79"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dns.html#gae84449f60dca6b863142daca8e03ce79">dns_gethostbyname_addrtype</a> (const char *hostname, <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *addr, <a class="el" href="dns_8h.html#ab5a9dec5b22802f91876c53e99f427ae">dns_found_callback</a> found, void *callback_arg, u8_t dns_addrtype)</td></tr>
<tr class="separator:gae84449f60dca6b863142daca8e03ce79"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Implements a DNS host name to IP address resolver.</p>
<p>The lwIP DNS resolver functions are used to lookup a host name and map it to a numerical IP address. It maintains a list of resolved hostnames that can be queried with the dns_lookup() function. New hostnames can be resolved using the <a class="el" href="structdns__query.html">dns_query()</a> function.</p>
<p>The lwIP version of the resolver also adds a non-blocking version of <a class="el" href="group__netdbapi.html#ga39746b4b096060ca3e8c6ee7a7560b1d">gethostbyname()</a> that will work with a raw API application. This function checks for an IP address string first and converts it if it is valid. <a class="el" href="group__netdbapi.html#ga39746b4b096060ca3e8c6ee7a7560b1d">gethostbyname()</a> then does a dns_lookup() to see if the name is already in the table. If so, the IP is returned. If not, a query is issued and the function returns with a ERR_INPROGRESS status. The app using the dns client must then go into a waiting state.</p>
<p>Once a hostname has been resolved (or found to be non-existent), the resolver code calls a specified callback function (which must be implemented by the module that uses the resolver).</p>
<p>Multicast DNS queries are supported for names ending on ".local". However, only "One-Shot Multicast DNS Queries" are supported (RFC 6762 chapter 5.1), this is not a fully compliant implementation of continuous mDNS querying!</p>
<p>All functions must be called from TCPIP thread.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__lwip__opts__dns.html#ga9f9881c887a8aceb9765820c2dbdf292">DNS_MAX_SERVERS</a> </dd>
<dd>
<a class="el" href="group__lwip__opts__dhcp.html#ga60ccc20fbb08be24b5d5f599dd47a6a6">LWIP_DHCP_MAX_DNS_SERVERS</a> </dd>
<dd>
<a class="el" href="group__netconn__common.html">Common functions</a> for thread-safe access. </dd></dl>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga1e040ec38166dc9bfcc3473aab0c799f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1e040ec38166dc9bfcc3473aab0c799f">&#9670;&nbsp;</a></span>dns_gethostbyname()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> dns_gethostbyname </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>hostname</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="dns_8h.html#ab5a9dec5b22802f91876c53e99f427ae">dns_found_callback</a>&#160;</td>
          <td class="paramname"><em>found</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>callback_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Resolve a hostname (string) into an IP address. NON-BLOCKING callback version for use with raw API!!!</p>
<p>Returns immediately with one of err_t return codes:</p><ul>
<li>ERR_OK if hostname is a valid IP address string or the host name is already in the local names table.</li>
<li>ERR_INPROGRESS enqueue a request to be sent to the DNS server for resolution if no errors are present.</li>
<li>ERR_ARG: dns client not initialized or invalid hostname</li>
</ul>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">hostname</td><td>the hostname that is to be queried </td></tr>
    <tr><td class="paramname">addr</td><td>pointer to a ip_addr_t where to store the address if it is already cached in the dns_table (only valid if ERR_OK is returned!) </td></tr>
    <tr><td class="paramname">found</td><td>a callback function to be called on success, failure or timeout (only if ERR_INPROGRESS is returned!) </td></tr>
    <tr><td class="paramname">callback_arg</td><td>argument to pass to the callback function </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a err_t return code. </dd></dl>

</div>
</div>
<a id="gae84449f60dca6b863142daca8e03ce79"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae84449f60dca6b863142daca8e03ce79">&#9670;&nbsp;</a></span>dns_gethostbyname_addrtype()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> dns_gethostbyname_addrtype </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>hostname</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="dns_8h.html#ab5a9dec5b22802f91876c53e99f427ae">dns_found_callback</a>&#160;</td>
          <td class="paramname"><em>found</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>callback_arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>dns_addrtype</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Like dns_gethostbyname, but returned address type can be controlled: </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">hostname</td><td>the hostname that is to be queried </td></tr>
    <tr><td class="paramname">addr</td><td>pointer to a ip_addr_t where to store the address if it is already cached in the dns_table (only valid if ERR_OK is returned!) </td></tr>
    <tr><td class="paramname">found</td><td>a callback function to be called on success, failure or timeout (only if ERR_INPROGRESS is returned!) </td></tr>
    <tr><td class="paramname">callback_arg</td><td>argument to pass to the callback function </td></tr>
    <tr><td class="paramname">dns_addrtype</td><td>- LWIP_DNS_ADDRTYPE_IPV4_IPV6: try to resolve IPv4 first, try IPv6 if IPv4 fails only<ul>
<li>LWIP_DNS_ADDRTYPE_IPV6_IPV4: try to resolve IPv6 first, try IPv4 if IPv6 fails only</li>
<li>LWIP_DNS_ADDRTYPE_IPV4: try to resolve IPv4 only</li>
<li>LWIP_DNS_ADDRTYPE_IPV6: try to resolve IPv6 only </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gad02111a6b26b93f1c3580d5f41a59af3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad02111a6b26b93f1c3580d5f41a59af3">&#9670;&nbsp;</a></span>dns_getserver()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a>* dns_getserver </td>
          <td>(</td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>numdns</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Obtain one of the currently configured DNS server.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">numdns</td><td>the index of the DNS server </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>IP address of the indexed DNS server or "ip_addr_any" if the DNS server has not been configured. </dd></dl>

</div>
</div>
<a id="gaf66c5d8273f83cdc2cdd8911fb68d584"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf66c5d8273f83cdc2cdd8911fb68d584">&#9670;&nbsp;</a></span>dns_setserver()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void dns_setserver </td>
          <td>(</td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>numdns</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dnsserver</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Initialize one of the DNS servers.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">numdns</td><td>the index of the DNS server to set must be &lt; DNS_MAX_SERVERS </td></tr>
    <tr><td class="paramname">dnsserver</td><td>IP address of the DNS server to set </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
